/*
 * @Author: 刘鑫
 * @Date: 2020-11-20 09:56:12
 * @LastEditors: 刘鑫
 * @LastEditTime: 2020-11-20 15:58:41
 * @Description:
 */
import { useState } from 'react';
import {
  getHomeData,
  getBrandDetail,
  getBrandDetailList,
  getTopicDetail,
  getComment,
} from '@/api/home';
import { IBrand, IComment } from '@/utils/types';
interface IPeops {
  (key: string): void;
}
export default function useHomeModel() {
  //   let [list,setList] =useState([])
  async function homeData(): Promise<any> {
    let result = await getHomeData();
    return result;
    //    return setList(result.data.banner)
  }
  async function detailData(id: string): Promise<any> {
    let result = await getBrandDetail(id);
    return result.data.brand;
  }
  // 制造商Id获取商品
  async function detailDataList(obj: IBrand): Promise<any> {
    let result = await getBrandDetailList(obj);
    return result.data.data;
  }
  //专题
  async function topicDetailData(id: string): Promise<any> {
    let result = await getTopicDetail(id);
    return result.data;
  }
  //评论
  async function commentlData(obj: IComment): Promise<any> {
    let result = await getComment(obj);
    return result.data.data;
  }
  return {
    homeData,
    detailData,
    detailDataList,
    topicDetailData,
    commentlData,
  };
}
